package com.bxd.baodan.activity;



import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings.RenderPriority;
import android.webkit.WebView;
import android.widget.ProgressBar;
import android.widget.Toast;

import com.bxd.baodan.R;

/**
 * 问答列表 计划书详情
 * 
 * @author wangxiaobo
 * 
 *         2014.8.27
 */

public class PlanDetailActivity extends BaseActivity {
	public WebView mWebView;
	private ProgressBar progressbar;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		this.getWindow().requestFeature(Window.FEATURE_PROGRESS); 
		super.onCreate(savedInstanceState);
		setContentView(R.layout.plan_detail);
		mWebView = (WebView) this.findViewById(R.id.plan_webview);
		progressbar = (ProgressBar) this.findViewById(R.id.progressbar);
		mWebView.getSettings().setJavaScriptEnabled(true);
		mWebView.getSettings().setBuiltInZoomControls(true);
		mWebView.getSettings().setUseWideViewPort(true);
		mWebView.getSettings().setRenderPriority(RenderPriority.HIGH);
		
		mWebView.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View arg0) {
				Toast.makeText(PlanDetailActivity.this, "webView点击了！", 1).show();
			}
		});
		mWebView.setWebChromeClient(new WebChromeClient() {
			@Override
			public void onProgressChanged(WebView view, int newProgress) {
				// 当加载到100%的时候 进度条自动消失
				progressbar.setProgress(newProgress);   
				progressbar.postInvalidate();   
                 if (newProgress == 100) {   
                	 progressbar.setVisibility(View.GONE);   
                 }   
			}
		});
		//取出计划书url
		Intent intent = getIntent();
		String planUrl =intent.getStringExtra("planUrl");
		if(planUrl != null && planUrl.length() !=0){
			mWebView.loadUrl(planUrl);
		} else {
			Toast.makeText(PlanDetailActivity.this, "url为空！", 1).show();
		}
		
	}
	
}
